home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7354 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: newsfeed.direct.ca!usenet
  2. From: etoivane@direct.ca (Ed Toivanen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to check array lenght?
  5. Date: 25 Feb 1996 21:47:02 GMT
  6. Organization: Your Organization
  7. Message-ID: <4gqlcm$jno@aphex.direct.ca>
  8. References: <4gbphl$ht@malakor.kku.ac.th>
  9. NNTP-Posting-Host: 204.174.243.150
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.6
  13.  
  14. In article <4gbphl$ht@malakor.kku.ac.th>, terdthai@kku1.kku.ac.th says...
  15. >
  16. >In subroutine that recieve pointer of array.
  17. >How to check number of multidimention array in that routine?
  18.  
  19. You can't there is no standard way to check the size of a non zero-terminated 
  20. array.  You have to pass the size of the array along with the array. 
  21. Personally, I encapsulate the array along with its current size in a struct:
  22.  
  23. typedef tagarray{
  24.     DATA* array;
  25.     int  size=MAX_SIZE;
  26. }ARRAY;
  27.  
  28. /*blah, blah, blah*/
  29. ARRAY anArray[MAX_SIZE];
  30.  
  31. func(anArray);
  32.  
  33. /*blah, blah, blah*/
  34. void func(ARRAY * ary);
  35. if(func->int > MAXSIZE){
  36. /*do some cool stuff*/
  37. }
  38.  
  39. Thats it
  40. Ed
  41.  
  42.